package com.project.mapper;

import com.project.bean.UserBean;
import org.apache.ibatis.annotations.*;

import java.time.LocalDate;
import java.util.List;

/**
 * @Title: IUserMapper
 * @Package: com.project.mapper
 * @Description:
 * @Author: Liang-Xie
 * @Date: 2022/7/13 - 17:31
 */
@SuppressWarnings("all")
public interface IUserMapper {
    @Insert("insert into t_user(u_username,u_password,u_birthday,u_rank)" +
            "values(#{name},#{password},#{birthday},#{rank})")
    public void add(UserBean userBean);

    @Delete("delete from t_user where pk_userId=#{id}")
    public void del(Integer id);

    @Update("update t_user set u_password=#{password}, u_rank=#{rank} where pk_userId=#{id}")
    public void update(@Param("id") Integer id, @Param("password") String password, @Param("rank") String rank);

    @Select("select * from t_user where u_userName=#{name} and u_password=#{password}")
    @ResultMap("userMap")
    public UserBean check(String name, String password);

    @Select("select * from t_user where pk_userId=#{id}")
    @ResultMap("userMap")
    public UserBean findById(Integer id);


    public List<UserBean> findByItem(@Param("name")String name,@Param("startBirthday")LocalDate startBirthday,@Param("endBirthday")LocalDate endBirthday);

    public List<UserBean> cutList(@Param("name") String name,
                                     @Param("startBirthday") LocalDate startBirthday,
                                     @Param("endBirthday") LocalDate endBirthday,
                                     @Param("startRow") Integer startRow,
                                     @Param("pageSize") Integer pageSize);

    public int cutCount(@Param("name") String name,
                        @Param("startBirthday") LocalDate startBirthday,
                        @Param("endBirthday") LocalDate endBirthday);


}
